package AbstractTests;

import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import Impl.Bloc;
import Impl.Type;
import Services.BlocService;

public abstract class AbstractBlocServiceTest {
	private BlocService bloc;
	
	protected AbstractBlocServiceTest() {
		bloc = null;
	}
	
	protected final BlocService getBloc() {
		return bloc;
	}
		
	protected final void setBloc(BlocService bloc) {
		this.bloc = bloc;
	}

	@Before
	public abstract void beforeTests(); 

	@After
	public final void afterTests() {
		bloc = null;
	}
	
	@Test 
	public void testPostInit_1(){
		// Conditions Initiales
		
		// Operations
		bloc.init(Type.Vide);
		
		// Oracle
		assertTrue(Type.Vide==bloc.getType() && Type.Vide==bloc.getOldType());
	}
	
	@Test
	public void testPostClone_1(){
		// Conditions Initiales
		BlocService b = new Bloc();
		b.init(Type.Mur);
		
		// Operations
		bloc.clone(b);
		
		assertTrue(bloc.getType()==b.getType() && bloc.getOldType()==b.getOldType());
	}
	
	@Test
	public void testPostChangeType_1(){
		// Conditions Initiales
		bloc.init(Type.Vide);

		// Operations
		bloc.ChangeType(Type.Mur);

		// Oracle
		assertTrue(bloc.getType()==Type.Mur && bloc.getOldType()==Type.Vide);
	}
	
}
